package com.biu.billiards.controller;


import com.biu.billiards.config.OperationAnnotation;
import com.biu.billiards.model.Login.WxLoginVo;
import com.biu.billiards.model.vo.shop.AddShopVo;
import com.biu.billiards.model.vo.shop.GetShopVo;
import com.biu.billiards.model.vo.shop.UpdateShopVO;
import com.biu.billiards.model.vo.user.AddUserVo;
import com.biu.billiards.model.vo.user.GetUserVo;
import com.biu.billiards.model.vo.user.UpdateUserVO;
import com.biu.billiards.response.BaseResponse;
import com.biu.billiards.response.RespGenerator;
import com.biu.billiards.service.IShopService;
import com.biu.billiards.service.IUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xue
 * @since 2023-09-25
 */
@RestController
@RequestMapping()
public class UserController {


    @Resource
    private IUserService userService;


    @ApiOperation(value = "获取个人信息")
    @PostMapping("/wx/getInfo")
    public BaseResponse<Boolean> getInfo(@RequestBody WxLoginVo wxLoginVo, HttpServletRequest request) {
        return RespGenerator.returnOK(userService.getInfo(wxLoginVo,request));

    }

    @ApiOperation(value = "微信登录")
    @PostMapping("/wx/userData")
    @OperationAnnotation(content="微信用户数据",sysType=0,opType=0,action="微信用户数据")
    public BaseResponse<HashMap> wxLogin(@RequestBody WxLoginVo wxLoginVo) {

        return RespGenerator.returnOK(userService.wxLogin(wxLoginVo));
    }



    @ApiOperation(value = "充值")
    @PostMapping("/topUp")
    public BaseResponse<Map<String,Object>> topUp(@RequestBody GetUserVo getUserVo) {
        return RespGenerator.returnOK(userService.topUp(getUserVo));
    }


    @ApiOperation(value = "获取用户数据")
    @PostMapping("/getUserPage")
    public BaseResponse<Map<String,Object>> getUserPage(@RequestBody GetUserVo getUserVo) {
        return RespGenerator.returnOK(userService.getUserPage(getUserVo));
    }


    @ApiOperation(value = "修改用户信息")
    @PutMapping("/updateUser")
    public BaseResponse<Boolean> updateUser(@RequestBody UpdateUserVO updateUserVO) {
        return RespGenerator.returnOK(userService.updateUser(updateUserVO));
    }


    @ApiOperation(value = "新增用户信息")
    @PostMapping("/addUser")
    public BaseResponse<Boolean> addUser(@RequestBody AddUserVo addUserVo) {
        return RespGenerator.returnOK(userService.addUser(addUserVo));
    }


    @ApiOperation(value = "删除用户信息")
    @DeleteMapping("/deleteUser")
    public BaseResponse<Boolean> deleteUser(@RequestParam("userId") Integer userId) {
        return RespGenerator.returnOK(userService.deleteUser(userId));
    }

}
